offset 471B80


#define
npc.graphic = [edi+94]

moneyvar    = [EBP-4]
#enddefine

PUSH EBP
MOV EBP,ESP
sub esp, 4
push 1
setpointer
MOV ecx, npc.deathsound
PUSH ECX
CALL Playsound
ADD ESP,8

mov eax npc.deathgraphic
cmp eax, 0
je :death_graphic_function_end
cmp eax, 2
jl :death_graphic_1
je :death_graphic_2
cmp eax, 3
je :Death_graphic_3
jmp :death_graphic_function_end
:death_graphic_1
push 3
jmp :DG_END
:death_graphic_2
push 7
jmp :DG_END
:Death_graphic_3
push 0C
:DG_END
mov edx, npc.graphic
push edx
mov ecx, npc.y
push ecx
mov eax, npc.X
push EAX
call 46F150          //explosion_create
add esp, 10
:death_graphic_function_end 
cmp npc.exp, 0  //skip exp/heart/missle if no exp
JE :Drop_done
:spawn_choose
push 5
push 1
call random  
add esp, 8
CMP eax,1
JE :Heart_spawn
CMP eax,3
JL :Missle_spawn
JE :Money_spawn
JMP :EXP_spawn









:Money_spawn
mov eax npc.exp
mov moneyvar eax
:loop_money
cmp moneyvar, A
jge :spawn_big_money
cmp moneyvar, 5
jge :spawn_medium_money
cmp moneyvar, 1
jl :money_spawn_done
mov ebx, 1
jmp :money_create

:spawn_medium_money
mov ebx, 5
jmp :money_create

:spawn_big_money
mov ebx, A
:money_create
sub moneyvar, ebx
push 10
push 1
push ebx //direction but just our arg actually
push 0   //Y velocity
push 0   //X velocity 
mov eax, npc.Y
mov ebx, npc.X
push eax
push ebx
push E //santa's key         
call 46efd0   
add esp,20
jmp :loop_money
:money_spawn_done
jmp :Drop_done









:Heart_spawn
mov eax CurrentHealth   //if at max health don't spawn hearts
cmp eax Maxhealth
je :spawn_choose  
CMP npc.EXP,6  //EXP value 6 or less
JLE :heart_exp_less
MOV eax,6
JMP :spawn_heart_ok
:heart_exp_less
MOV eax,2
:spawn_heart_ok
PUSH EAX
MOV EDX, npc.Y
PUSH EDX
MOV ECX, npc.x
PUSH ECX
CALL 0046F630  //spawn heart
ADD ESP,0C
JMP :Drop_done

:Missle_spawn
push  5 //missle launcher value 
call 401F60
add esp, 4
test eax, eax
je :spawn_choose

CMP npc.EXP,6
JLE :set_to_1
MOV eax,3   //big missles
JMP :Set_to_3
:set_to_1
MOV eax,1
:Set_to_3
PUSH EAX 
mov eax, npc.Y
push eax
mov eax, npc.X
push eax
CALL 0046F430   //spawn missle
ADD ESP,0C
TEST EAX,EAX
Jne :Drop_done

:EXP_spawn
MOV EAX, npc.EXP
PUSH EAX
MOV EDX, npc.Y
PUSH EDX 
MOV ECX, npc.X
PUSH ECX
CALL 0046F2B0   //spawn exp
ADD ESP,0C

:Drop_done
MOV EAX, npc.entityID
PUSH EAX
CALL 0040E890 //not sure...
ADD ESP,4
MOV EDX, npc.flags
AND EDX,00008000
JE :die_npc

CMP npc.DamageTaken,0
JE :don't_draw_damage
//draw damage taken
MOV ECX, npc.damagetaken
PUSH ECX
mov EDX, EDI
ADD EDX,0C
PUSH EDX
mov EAX, EDI
ADD EAX,8
PUSH EAX
CALL 00425BF0 
ADD ESP,0C
:don't_draw_damage

CMP DWORD PTR SS:[EBP+0C],0  //I'm not sure what this is to be honest
JE :end_of_code
MOV ECX,DWORD PTR SS:[EBP+8]
PUSH ECX   
CALL 0046F760     //or this but it's in the vanilla code so I'm leaving it here
ADD ESP,4
JMP :end_of_code

:die_npc
MOV ECX,DWORD PTR SS:[EBP+8]
MOV BYTE PTR DS:[ECX],0   //npc.inuse, 0
:end_of_code
MOV ESP,EBP
POP EBP
RETN




